class Solution(object):
    def arrangeCoins(self, n):
        """
        :type n: int
        :rtype: int
        """
        # i = 1
        # while True:
        #     if sum(range(0, i+1)) == n:
        #         return i
        #         break
        #     if sum(range(0, i)) < n < sum(range(0, i+1)):
        #         return i-1
        #         break
        #     i += 1
        i, total = 0, 0
        while total <= n:
            i += 1
            total += i
        return i - 1



if __name__ == '__main__':
    print(Solution().arrangeCoins(8))
